//
//  APWorksDetailHeaderView.m
//  AqualPolo
//
//  Created by dong on 2024/5/10.
//

#import "APWorksDetailHeaderView.h"

@implementation APTranslateControl

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 12;
        self.layer.masksToBounds = true;
        self.layer.borderWidth = 1;
        self.layer.borderColor = LYRGBColor(45, 116, 255).CGColor;
        [self setGradientBackgroundWithColors:@[LYRGBColor(19, 78, 104),LYRGBColor(25, 15, 85)] locations:@[@0,@1] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        _imageView = [[UIImageView alloc]init];
        _imageView.image = [UIImage imageNamed:@"translate_icon"];
        [self addSubview:_imageView];
        [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10);
            make.centerY.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(14, 14));
        }];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = LYRGBColor(45, 116, 255);
        _titleLabel.font = [LYFont fontWithSize:11 fontName:LYFontNamepfr];
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.text = @"Translate";
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_imageView.mas_right).offset(4);
            make.top.bottom.equalTo(self);
            make.right.equalTo(self).offset(-10);
        }];
    
        
    }
    return self;
}

@end

@implementation APWorksDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _imagesView = [[APPublicTimerDisplayView alloc] init];
        _imagesView.isPageVisible = YES;
        _imagesView.isAutoScroll = false;
        _imagesView.layer.cornerRadius = 30;
        _imagesView.layer.maskedCorners = kCALayerMaxXMaxYCorner | kCALayerMinXMaxYCorner;
        [_imagesView setPageControlStyle:DisplayViewPageControlStyleDefault];
        _imagesView.layer.masksToBounds = true;
        [self addSubview:_imagesView];
        [_imagesView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.equalTo(self);
            make.height.mas_equalTo(304);
        }];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.font = [LYFont fontWithSize:16 fontName:LYFontNamepfm];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_imagesView.mas_bottom).offset(16);
            make.left.equalTo(self).offset(20);
            make.right.equalTo(self).offset(-20);
        }];
        
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.textColor = LYRGBAColor(255, 255, 255, 0.8);
        _contentLabel.font = [LYFont fontWithSize:12 fontName:LYFontNamepfr];
        _contentLabel.textAlignment = NSTextAlignmentCenter;
        _translateContentLabel.numberOfLines = 0;
        [self addSubview:_contentLabel];
        [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(16);
            make.left.equalTo(self).offset(20);
            make.right.equalTo(self).offset(-20);
        }];
        _translateContentLabel = [[UILabel alloc] init];
        _translateContentLabel.textColor = LYRGBAColor(255, 255, 255, 0.8);
        _translateContentLabel.font = [LYFont fontWithSize:12 fontName:LYFontNamepfr];
        _translateContentLabel.textAlignment = NSTextAlignmentCenter;
        _translateContentLabel.numberOfLines = 0;
        [self addSubview:_translateContentLabel];
        [_translateContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_contentLabel.mas_bottom).offset(16);
            make.left.equalTo(self).offset(20);
            make.right.equalTo(self).offset(-20);
        }];
        
        
        _translateControl = [[APTranslateControl alloc] init];
        [self addSubview:_translateControl];
        [_translateControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self).offset(-30);
            make.left.equalTo(self).offset(20);
            make.height.mas_equalTo(24);
        }];
        
        
        _upvoteButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_upvoteButton setBackgroundImage:[UIImage imageNamed:@"upvote_blue_rect_n"] forState:UIControlStateNormal];
        [_upvoteButton setBackgroundImage:[UIImage imageNamed:@"upvote_blue_rect_h"] forState:UIControlStateSelected];
        [self addSubview:_upvoteButton];
        [_upvoteButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-20);
            make.centerY.equalTo(_translateControl.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(28, 28));
        }];
        
        
    }
    return self;
}
@end
